<?
require_once("conn.php");
?>
<script>
	
</script>
<table width="100%">
	<tr>
		<td><a href="#" onclick="buyOfficeStock()">Buy to Stock</a></td>
		<td><a href="#" onclick="removeOfficeStock()">Remove From Stock</a></td>
	</tr>
</table>
<hr>
<table width="100%" cellpadding="0" cellspacing="0">
	<tr>
		<td>Barcode</td>
		<td>Product Name</td>
		<td>Category</td>
		<td>Qty</td>
		<td>Unit</td>
		<td>Expired</td>
		<td>Last Update</td>
	</tr>
	<?
		$sql = "SELECT a.id as id,product_name,category_name,a.barcode as barcode,qty,DATE_FORMAT(STR_TO_DATE(expired_date, '%d%m%Y'), '%d/%m/%Y') as expired_date,unit_name,last_update FROM (pch_stock_office as a join (pch_product as b join pch_category as c on b.category_id=c.id) on a.item_id=b.id) LEFT JOIN pch_unit as d on a.unit=d.id ORDER BY STR_TO_DATE(expired_date, '%d%m%Y');";
		//echo $sql;
		$query = mysql_query($sql)or die(mysql_error());
		while($row = mysql_fetch_array($query)){
		?>
			<tr>
				<td><?=$row["barcode"]?></td>
				<td><?=$row["product_name"]?></td>
				<td><?=$row["category_name"]?></td>
				<td><?=$row["qty"]?></td>
				<td><?=$row["unit_name"]?></td>
				<td><?=$row["expired_date"]?></td>
				<td><?=$row["last_update"]?></td>
		<?
		}
	?>
</table>
